import http from "@/utils/http";
import type { annexTypeDataItem, annexTypeAddParams, addAnnexFieldParams, annexFieldDataItem } from "./type";

/**
 * 附件分类列表
 */
export const annexConfigList = () => {
  return http.get<annexTypeDataItem[]>("/crm/profile/categoryList");
};

/**
 * 附件分类排序
 */
export const sortAnnexConfig = (data: string[]) => {
  return http.post("/crm/profile/orderNumCategory", data);
};

/**
 * 新增附件分类
 */
export const addAnnexConfig = (data: annexTypeAddParams) => {
  return http.post(`/crm/profile/addCategory?category=${data.category}`);
};

/**
 * 删除附件分类
 */
export const delAnnexConfig = (id: string) => {
  return http.deleteMethod(`/crm/profile/deleteCategory/${id}`);
};

/**
 * 附件字段列表
 */
export const annexFieldList = (id: string) => {
  return http.get<annexFieldDataItem[]>(`/crm/profile/profileTemplateList/${id}`);
};
/**
 * 附件字段排序
 */
export const sortAnnexField = (data: string[]) => {
  return http.post(`/crm/profile/orderNumProfile`, data);
};
/**
 * 新增附件字段
 */
export const addAnnexField = (data: addAnnexFieldParams) => {
  return http.post("/crm/profile/addProfile", data);
};

/**
 * 删除附件字段
 */
export const delAnnexField = (id: string) => {
  return http.deleteMethod(`/crm/profile/deleteProfile/${id}`);
};

/**
 * 设置附件是否在合同中使用
 */
export const setAnnexFieldUse = (id: string, enable: boolean) => {
  return http.post(`/crm/profile/setIsUse/${id}/${enable}`);
};
